Skip to content

Conversation

@aevyrie
Copy link
Member

@aevyrie aevyrie commented Jan 5, 2026

Objective

  • Implement contact shadows to add fine shadow detail where shadow cascades cannot.

Solution

  • Extend our existing pbr implementation using our existing raymarching functions.

Showcase

image image
Screen.Recording.2026-01-07.at.11.18.18.PM.mp4
Screen.Recording.2026-01-04.at.7.19.25.PM.mp4
Screen.Recording.2026-01-04.at.7.36.03.PM.mp4
image image image image image image

Copy link
Member

@tychedelia tychedelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding or updating an existing example?

@aevyrie
Copy link
Member Author

aevyrie commented Jan 5, 2026

Sure, I was going to ask the crowd where it would make sense to add to an example.

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen M-Release-Note Work that should be called out in the blog due to impact S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Jan 5, 2026
@alice-i-cecile alice-i-cecile added this to the 0.19 milestone Jan 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note.

Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes.

@JMS55
Copy link
Contributor

JMS55 commented Jan 5, 2026

Closes #16164

@JMS55
Copy link
Contributor

JMS55 commented Jan 5, 2026

Does it make sense to do the raymarching directly in the material shader? It might give better perf to pull it out to its own pass.

Also MeshletMesh needs testing with this feature (and in the various forward/deferref/prepass modes).

@pcwalton
Copy link
Contributor

pcwalton commented Jan 5, 2026

I have an example for contact shadows that I made in my old branch: https://github.com/pcwalton/bevy/blob/contact-shadows/examples/3d/contact_shadows.rs

Feel free to steal it if you want, or not (it's rather old and would need to be updated). Up to you :)

@pcwalton
Copy link
Contributor

pcwalton commented Jan 5, 2026

@JMS55 I don't think the raymarching can really be done anywhere else, because in forward you need to know what's in shadow right then. You can't really subtract a light after the fact. (Well, maybe you technically could make it work, but that'd be a huge can of worms.)

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

@aevyrie
Copy link
Member Author

aevyrie commented Jan 8, 2026

This 07f2b89 commit adds a bunch of diffs from renaming the shadow map setting, per discord.

@JMS55
Copy link
Contributor

JMS55 commented Jan 9, 2026

@aevyrie can we break the shadow map renaming code out into a new PR?

@aevyrie
Copy link
Member Author

aevyrie commented Jan 9, 2026

Sure, would that add any value? shadows_enabled is a bit misleading without a rename.

@JMS55
Copy link
Contributor

JMS55 commented Jan 10, 2026

It would help for review, but also e.g. Solari has shadows, but dosen't use shadow maps, so it's already misleading as-is.

Copy link
Contributor

@pcwalton pcwalton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@tychedelia tychedelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks great. Thanks for working on this!

Re: the rename, I think this is fine and it's better to err on the side of specificity. I think there's a bigger conversation to be had about UX when it comes to lighting that isn't going to swing on a rename.

@tychedelia tychedelia added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 12, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 13, 2026
@alice-i-cecile
Copy link
Member

Guess what, it's "binding errors on web" time!

In Device::create_render_pipeline, label = 'pbr_opaque_mesh_pipeline'
In the provided shader, the type given for group 0 binding 16 has a size of 12. As the device does not support DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED, the type must have a size that is a multiple of 16 bytes.

Co-authored-by: charlotte 🌸 <[email protected]>
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 13, 2026
github-merge-queue bot pushed a commit that referenced this pull request Jan 13, 2026
# Objective

- Implement contact shadows to add fine shadow detail where shadow
cascades cannot.

## Solution

- Extend our existing pbr implementation using our existing raymarching
functions.

---

## Showcase

<img width="1824" height="1180" alt="image"
src="https://github.com/user-attachments/assets/e93b79c5-c596-4a9e-b94d-20bdde1d863b"
/>

<img width="1824" height="1180" alt="image"
src="https://github.com/user-attachments/assets/0fd7dffa-60b8-4b92-8fad-7f993d4d89dd"
/>


https://github.com/user-attachments/assets/e74b190d-9ae3-4aaf-97f0-b520930a0667


https://github.com/user-attachments/assets/e80ccb26-bbaa-4d25-a823-8ea12354c5b9


https://github.com/user-attachments/assets/b04f4b00-92bd-4a2f-b7dd-5157d8fbe0ab

<img width="1073" height="685" alt="image"
src="https://github.com/user-attachments/assets/b7629908-dd32-48db-8ee7-a4d2dd8f66c2"
/>

<img width="1073" height="685" alt="image"
src="https://github.com/user-attachments/assets/3de0258e-9191-4180-ac57-41b32e1205bd"
/>

<img width="1073" height="685" alt="image"
src="https://github.com/user-attachments/assets/951477f9-e9a9-426f-ae8d-18ae50cc7b85"
/>

<img width="1073" height="685" alt="image"
src="https://github.com/user-attachments/assets/2291453c-da57-4fcc-a6b0-f60f6eac6cbb"
/>

<img width="1073" height="685" alt="image"
src="https://github.com/user-attachments/assets/5820cdff-ea54-4294-b520-2a8d8dc24996"
/>

<img width="1073" height="685" alt="image"
src="https://github.com/user-attachments/assets/3ea16481-7689-4e99-87e2-1589f1532e4c"
/>

---------

Co-authored-by: Alice Cecile <[email protected]>
Co-authored-by: charlotte 🌸 <[email protected]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 13, 2026
Co-authored-by: charlotte 🌸 <[email protected]>
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 13, 2026
Merged via the queue into bevyengine:main with commit a88af65 Jan 13, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide M-Release-Note Work that should be called out in the blog due to impact S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants